package dog.weatherwallpaper.utils;

public enum Conversion {
	;
	/**
	 * Converts temperature in celsius to fahrenheit.
	 */
	public static int ctof(final int f) {
		float n = (float) f - 32;
		return (int) Math.round(n * 5 / 9);
	}

	/**
	 * Converts temperature in fahrenheit to celsius.
	 */
	public static int ftoc(final int c) {
		float n = (float) c;
		return (int) Math.round(n * 9 / 5) + 32;
	}

	/**
	 * Converts density-independent pixels to pixels.
	 */
	public static int dpToPx(final int dp) {
		final float ratio = App.context().getResources().getDisplayMetrics().density;
		return Math.round(dp * ratio);
	}

	/**
	 * Converts pixels to density-independent pixels.
	 */
	public static int pxToDp(final int px) {
		final float ratio = App.context().getResources().getDisplayMetrics().density;
		return Math.round(px / ratio);
	}
}